#include<cstdio>
const int maxn=50010;
int p[maxn],r[maxn];
int find(int i)
{
	int k,t,j=i;
	while(p[j]!=j)j=p[j];
	for(k=i;p[k]!=k;)
	{
		t=k;
		k=p[k];
		p[t]=j;
	}
	return j;
}
void merge(int i,int j)
{
	int r1=find(i);
	int r2=find(j);
	if(r1!=r2)
	{
		if(r[r1]>r[r2])p[r2]=r1;
		else
		{
			p[r1]=r2;
			if(r[r1]==r[r2])r[r2]++;
		}
	}
}
int main()
{
	int n,m,cas=0;
	while(scanf("%d%d",&n,&m)&&n)
	{
		cas++;
		for(int i=1;i<=n;i++)p[i]=i;
		for(int i=1;i<=m;i++)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			merge(x,y);
		}
		int ans=0;
		for(int i=1;i<=n;i++)
			if(find(i)==i)ans++;
		printf("Case %d: %d\n",cas,ans);
	}
	return 0;
}




